package com.liusand.admin.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


/**
 * @author LiuSha
 */
@WebFilter("/*")
@Component
@Slf4j
public class AStaticFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        String requestURI = request.getRequestURI();

        log.info(requestURI);
        request.setAttribute("flag", requestURI.endsWith(".html") || requestURI.endsWith(".js") || requestURI.endsWith(".css"));

        filterChain.doFilter(servletRequest, servletResponse);

    }

}
